package com.suma.platform.core.util;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;

/**
 * @author suma
 * @date 2018/2/7 下午1:23
 */
public class Test {
	public static void main(String[] args) {
        Test test = new Test();
        test.testStudent();
	}

	Multimap<String, Student> multimap = ArrayListMultimap.create();

	private static final String CLASS_NAME_1 = "一年级";
	private static final String CLASS_NAME_2 = "二年级";

	public void testStudent() {

		for (int i = 0; i < 5; i++) {
			Student student = new Student();
			student.setName("Tom" + i);
			student.setAge(6);
			multimap.put(CLASS_NAME_1, student);
		}
		for (int i = 0; i < 5; i++) {
			Student student = new Student();
			student.setName("Jary" + i);
			student.setAge(7);
			multimap.put(CLASS_NAME_2, student);
		}

		for (Student stu : multimap.get(CLASS_NAME_1)) {
			System.out.println("一年级学生 name:" + stu.getName() + " age:" + stu.getAge());
		}
		// 判断键是否存在
		if (multimap.containsKey(CLASS_NAME_1)) {
			System.out.println("键值包含：" + CLASS_NAME_1);
		}
        System.out.println(multimap.get("123"));
        // ”键-单个值映射”的个数
		System.out.println(multimap.size());
		// 不同键的个数
		System.out.print(multimap.keySet().size());
	}
}
